package com.dz.risk.controller;

import com.dz.risk.common.ResponseVO;
import com.dz.risk.pojo.domain.BasicBondInformationEntity;
import com.dz.risk.pojo.model.PageModel;
import com.dz.risk.service.BasicBondInformationService;
import com.dz.risk.validation.Add;
import com.dz.risk.validation.Update;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 债卷基础信息表控制层
 *
 * @author Doke
 * @date 2021/7/13 15:31
 */
@Api(tags = "债卷基础信息Api")
@RestController
@RequestMapping("/dz-ftsp/stest/basicBondInformation")
public class BasicBondInformationController {

    private final BasicBondInformationService basicBondInformationService;

    @Autowired
    public BasicBondInformationController(BasicBondInformationService basicBondInformationService) {
        this.basicBondInformationService = basicBondInformationService;
    }

    @ApiOperation("新增债卷基础信息")
    @PostMapping("/add")
    public ResponseVO add(@RequestBody @Validated(Add.class) BasicBondInformationEntity basicBondInformationEntity) {
        basicBondInformationService.add(basicBondInformationEntity);
        return ResponseVO.ok();
    }

    @ApiOperation("更新债卷基础信息")
    @PostMapping("/updateById")
    public ResponseVO updateById(@RequestBody @Validated(Update.class) BasicBondInformationEntity basicBondInformationEntity) {
        basicBondInformationService.updateById(basicBondInformationEntity);
        return ResponseVO.ok();
    }

    @ApiOperation("根据Id删除债卷基础信息")
    @GetMapping("/deleteById")
    public ResponseVO deleteById(@RequestParam("id") String id) {
        basicBondInformationService.removeById(id);
        return ResponseVO.ok();
    }

    @ApiOperation("分页查询债卷基础信息 ")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "当前页(默认 : 1)", dataType = "Integer"),
            @ApiImplicitParam(name = "rows", value = "显示条数(默认 : 10)", dataType = "Integer"),
            @ApiImplicitParam(name = "bondName", value = "债券名称", dataType = "Integer"),
            @ApiImplicitParam(name = "bondCode", value = "债卷代码", dataType = "Integer"),
            @ApiImplicitParam(name = "bondType", value = "债卷类型(1 : 自有资金承接深分大集合债券 , 2 : 余额包销债券 , 3 : 计财投资证券（债券、同业存单))", dataType = "Integer")
    })
    @GetMapping("/pageList")
    public ResponseVO pageList(PageModel pageModel, String bondName, String bondCode, Integer bondType) {
        return ResponseVO.ok(basicBondInformationService.pageList(pageModel, bondName, bondCode, bondType));
    }
}
